<?php

class Silk_Application_Subsystem_SiteSwitcher implements FP_Application_Subsystem_Interface {

    protected $config = null;

    public function init($pConfig=null){

	$this->_config = $pConfig;

	if (!Silk::Get('DISABLE_SITE_SWITCHER')){

	    $domain = $_SERVER['HTTP_HOST'];

	    logdebug("Silk_Application_Subsystem_SiteSwitcher.init: Resolving $domain to site");
	    $Sites = new Silk_Sites();
	    $site  = $Sites->fetchByDomain($domain, true);

	    if (!$site)
		$site = $Sites->fetch(1);

	    logdebug("Silk_Application_Subsystem_SiteSwitcher.init: Setting current site to {$site->domain}");

	    Zend_Registry::set('silk_cms_current_site', $site);
	}
    }

    public static function GetCurrentSite(){
	return Zend_Registry::get('silk_cms_current_site');
    }
}

?>